package enterprise.web_jpa_war.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 * @author <a href="mailto:Roman_Boiko@epam.com">Roman Boiko</a>
 */

@Entity   
@Table
public class DeviceStateChangeHistory {
	@Id
        @GeneratedValue(strategy = GenerationType.TABLE)
	private Long id;
	
	@ManyToOne(cascade = CascadeType.PERSIST)
	private User user;
	
	@ManyToOne(cascade = CascadeType.PERSIST)
	private Device device;
	
	@ManyToOne(cascade = CascadeType.PERSIST)
	private DeviceState resultState;
	
	@Column(nullable=false)
        @Temporal(javax.persistence.TemporalType.DATE)
	private Date changeDate;
	
	public DeviceStateChangeHistory(){}
	
	public DeviceStateChangeHistory(User user, Device device,
			DeviceState resultState, Date changeDate, String comment) {
		super();
		this.user = user;
		this.device = device;
		this.resultState = resultState;
		this.changeDate = changeDate;
		this.comment = comment;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Device getDevice() {
		return device;
	}

	public void setDevice(Device device) {
		this.device = device;
	}

	public DeviceState getResultState() {
		return resultState;
	}

	public void setResultState(DeviceState resultState) {
		this.resultState = resultState;
	}

	public Date getChangeDate() {
		return changeDate;
	}

	public void setChangeDate(Date changeDate) {
		this.changeDate = changeDate;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	@Column
	private String comment;

}
